home *** CD-ROM | disk | FTP | other *** search
/ Precision Software Appli…tions Silver Collection 4 / Precision Software Applications Silver Collection Volume 4 (1993).iso / stats / chadyn.exe / YFETCH.C < prev    next >
Text File  |  1988-12-15  |  22KB  |  710 lines

  1. /************************************ YFETCH.C *******************************/
  2. /*********************** (C) 1986,7,8 by JAMES A. YORKE **********************/
  3. /********** ROUTINES in file:  (the order in which they appear is important)
  4. OpenFiles(argc,argv)
  5.     int argc;
  6.     char *argv[];
  7. titleAndMode()
  8.         sets up the screen
  9. NextArg() this is called when we want to check for the next argument on the 
  10.         command line; if there is not one, we will set 
  11.         argcGlob <= argNow ; otherwise if it is not a ':' command
  12.         (an entry beginning with a :), then we try to open it;
  13.         if it is a : command we set coloncommand = YES;
  14.         this is first called by OpenFiles 
  15. char *GetCrudeWord()  this fetches one "word", a 
  16.         collection of letters without white space; colon commands are 
  17.         commands on the command line coloncommand is set 
  18.         by NextArg();  
  19. char *GetGoodWord()    gets next word, excluding comments.
  20. int ParseString(niceString,givenstring,len,numstars)
  21.         The purpose of the following is to take commands and parse 
  22.         them so they can be interpretted; "parse" means discarding 
  23.         spaces and '*'s, and lowering the case of letters;
  24.         it gets string 'givenstring' of length up to LEN, deletes
  25.         spaces, changes Upper Case to lower case, puts resulting
  26.         digits and lower case letters and '-' and '+' signs 
  27.         in niceString; it aborts if illegal
  28.         character is encountered; returns quality = -1 if bad char is 
  29.         encountered or if string does not have '\0'; otherwise it 
  30.         returns number of characters,
  31.         a number which could be 0; a colon is 
  32.         accepted as a string terminator and later stuff is deleted;
  33.     char *niceString,*givenstring;
  34.     int len, *numstars;
  35. int GetCommand() GetCommand fetches a string from the input device which is 
  36.         either the keyboard or a disk file. It parses the string, 
  37.         making sure it has only legal characters, eliminating 
  38.         spaces and tabs and changing upper case letters to lower case. 
  39.         If it determines that the string is legal, a 1 is returned, 
  40.         otherwise 0; If it consists only of digits and possibly a 
  41.         minus sign, it sticks the numerical value in "CodeName". 
  42. char  *FindBeginning(docfile, HelpName, CodeName)
  43.         The routine is for fetching text from a document file whose
  44.         file pointer is "docfile"; it 
  45.         looks at line after line; ignore lines that do not begin with 
  46.                 '*';
  47.         first truncate any line beginning with a * so that it does 
  48.         not have any spaces between nontrivial characters, where 
  49.         trivial means ' ' or '*' or tab; 
  50.         then parse and decode the truncated 
  51.         string; if the returned code == helpcode, we have the desired
  52.         line and the routine returns a pointer to the line;
  53.         otherwise it returns NULL.
  54.     FILE    *docfile;
  55.     char    *HelpName;
  56. givehelp(StringReception, HelpName)
  57.     int StringReception;
  58.     char *HelpName;
  59. int CheckForInt(string)
  60.         This function returns the integer value if string[] is a 
  61.         positive integer other than -9999; if it is not an integer, 
  62.         it returns -9999 
  63.     char *string;
  64. int GetMapName() This routine gets the map name and parses it and returns 1 
  65.           if the name is acceptable; that does not guarantee that 
  66.          a process by that name exists 
  67. OptionsHelp()    called by interrupt() 
  68. getText(filename,option) this routine searches for a line beginning with an 
  69.         asterisk and the rest of the line matches OPTION exactlyu.
  70.         it then prints out the following lines up to but not including 
  71.         the next line that begins with an asterisk.
  72.     char *option, *filename;
  73. int TestForPic() returns 1 if file ends in .pic, and otherwise returns 0 
  74. int  keycheck() This routines checks to see if a key has been hit;
  75.         if not, it returns 0; if it has, it fetches the char and 
  76.         returns it; it may have to check twice since extended codes
  77.         preface a non zero character with a zero.
  78.         The X Windows version uses a different routine.
  79. ******************************************************************************/
  80. #define XINCLUDES
  81. #include "yinclud.h"
  82. #include <ctype.h>
  83.  
  84. static char *warning = 
  85. "*** Use upper case where appropriate; interrupts are CASE SENSITIVE ***   \n";
  86.  
  87.  
  88.  
  89. OpenFiles(argc, argv)
  90. int     argc;
  91. char   *argv[];
  92. {
  93. #ifndef X11
  94.     colorPlanes = picAlloc(); /* allocates space for picture */
  95. #endif
  96.  
  97.  
  98.     argNow = 0;        /* the first entry (number 0) is the name of
  99.                    the program at least on Unix systems */
  100.     argcGlob = argc;
  101.     argvGlob = argv;
  102.  
  103. #ifdef MAINFRAME
  104.     StandOutPut = fopen("OutScr", OPENFORWRITING);
  105.                 /* Opens file for writing to the a standard
  106.                    file in place of the screen */
  107.     StPrint = fopen("OutPrn", OPENFORWRITING);
  108.                 /* Opens file for writing to the a standard
  109.                    file in place of the standard printer */
  110. #else
  111.     StOutPut = stdout;
  112.     StPrint = stdprn;    /* this should be the only place stdout appears
  113.                    */
  114. #endif
  115.  
  116.     StInput = stdin;
  117.     NextArg();
  118.     titleAndMode();    /* set screen mode and plot title page */
  119. }
  120.  
  121. /* ------------------------------------------------------------------------- */
  122. titleAndMode() {        /* set screen mode and plot title page */
  123. #ifndef MAINFRAME
  124.     SetVidMode();        /* defined in YSCREEN.C */
  125. #endif                /* MAINFRAME */
  126.     jay();
  127. #ifndef MAINFRAME
  128. #ifndef unix
  129.     pause(1.2);        /* pause for this number of seconds */
  130. #endif                /* UNIX */
  131. #endif                /* MAINFRAME */
  132. }
  133. /* ------------------------------------------------------------------------- */
  134.  
  135. NextArg() {            /* this is called when we want to check for the
  136.                    next argument on the command line; if there
  137.                    is not one, we will set argcGlob <= argNow ;
  138.                    otherwise if it is not a ':' command(an
  139.                    entry beginning with a :), then we try to
  140.                    open it; if it is a : command we set
  141.                    coloncommand = YES; this is first called by
  142.                    OpenFiles */
  143.  
  144.     if(argcGlob > 0 && input != stdin && input != NULL)
  145.         fclose(input);
  146.     argNow++;
  147.     IsEndPIC = NO;
  148.     if(argcGlob > argNow) {/* notice that if argc(=argcGlob) is 5, then
  149.                    the command line arguments are numbered
  150.                    0,1,2,3,4 so if argNow is 5, we have
  151.                    exceeded our list */
  152.         if(argvGlob[argNow][0] == ':') {
  153.             coloncommand = YES;
  154.             input = StInput;
  155.         }
  156.         else {
  157.             IsEndPIC = TestForPic(argvGlob[argNow]);
  158.             coloncommand = NO;
  159.             if((input = fopen(argvGlob[argNow], "r")) == NULL)  {
  160.                 input = StInput;
  161.                 character_mode();
  162.                 PRINT
  163.                     "\n*********************************ERROR*******************************\n");
  164.                 PRINT
  165.                     "    PROGRAM CANNOT FIND THE FILE %s WHICH YOU SPECIFIED  \n"
  166.                     ,argvGlob[argNow]);
  167.                 PRINT
  168.                     "    ON THE COMMAND LINE.\n");
  169.                 PRINT
  170.                     "    IF THAT WAS SUPPOSED TO BE A COMMAND, PRECEDE IT WITH A ':' \n");
  171.                 PRINT
  172.                     "*****************************PROGRAM TERMINATES***********************\n");
  173.                 PRINT
  174.                     "                                J.A.Y.\n\n\n");
  175.  
  176.                 exit(1);
  177.             }
  178.         }        /* end else */
  179.     }
  180.     else {
  181.         coloncommand = NO;
  182.         status = 0;    /* this means the disk files are finished */
  183.         input = StInput;
  184.     }
  185. }
  186. /* ------------------------------------------------------------------------- */
  187. /* GETCRUDEWORD -  fetches and returns one "word", a collection of letters without
  188.  * white space; colon commands are commands on the command line and are 
  189.  * preceded by ':'; coloncommand is set by NextArg().
  190.  * Return NULL on end of file and a pointer to the next word otherwise.
  191.  */
  192. char *GetCrudeWord() 
  193. {        
  194. static char    CrudeString[MAXCHAR+1];
  195.     char    *word = CrudeString;
  196.  
  197.     if(coloncommand == YES) {
  198.         (void) strcpy(CrudeString, &argvGlob[argNow][1]);
  199.         PRINT ":%s", CrudeString);
  200.         ret_erase_line(2);
  201.         NextArg();
  202.     } else {
  203. #ifdef X11
  204.         if(input == StInput 
  205.             && sscanf(xwfgets(), "%s", CrudeString) == EOF ||
  206.            input != StInput 
  207.             && fscanf(input, "%s", CrudeString) == EOF)  {
  208.             PRINT "EOF\n");
  209.             CrudeString[0] = '\0';
  210.             word = NULL;
  211.         }
  212. #else
  213.         if(abortEnter() == YES)
  214.             CrudeString[0] = '\0';
  215.         else if(fscanf(input, "%s", CrudeString) == EOF) {
  216.             PRINT "EOF\n");
  217.             word = NULL;
  218.         }
  219. #endif
  220.     }
  221.     return(word);
  222. }
  223. /* ------------------------------------------------------------------------- */
  224. /* GETGOODWORD - get next crude word excluding comments.
  225.  * Comments are delimited by slash/asterisk pairs SEPARATED BY WHITE SPACE.
  226.  * When the end of the input is detected, we return the word "fileend".
  227.  */
  228. char    *GetGoodWord() 
  229. {
  230.     char    *CrudeString;
  231.  
  232.     CrudeString = GetCrudeWord();
  233.     if(strcmp(CrudeString, "/*") == 0)  {
  234.         do 
  235.             CrudeString = GetCrudeWord();
  236.         while(CrudeString != NULL && strcmp(CrudeString, "*/") != 0);
  237.         if(CrudeString != NULL && strcmp(CrudeString, "*/") == 0)
  238.             CrudeString = GetCrudeWord();
  239.     }
  240.     return(CrudeString == NULL ? "fileend" : CrudeString);
  241. }
  242. /* ------------------------------------------------------------------------- */
  243. #ifdef MS
  244. /* INDEX - works like the Unix subroutine of the same name which the MS C
  245.  * library is lacking.
  246.  */
  247. char    *index(s, ch)
  248. register char    *s;
  249. char    ch;
  250. {
  251.     if(s == NULL)
  252.         return(NULL);
  253.     while(*s != '\0' && *s != ch)
  254.         s++;
  255.     return(*s == ch ? s : NULL);
  256. }
  257. #endif  /* MS */
  258. /* ------------------------------------------------------------------------- */
  259. /* PARSESTRING - Take commands and parse them so
  260.  * they can be interpreted; "parse" means discarding spaces and '*'s, and
  261.  * lowering the case of letters; it gets GIVENSTRING of length up
  262.  * to LEN, deletes spaces, changes Upper Case to lower case, puts
  263.  * resulting digits and lower case letters and '-' and '+' signs in
  264.  * NICE; it aborts if illegal character is encountered; returns -1
  265.  * if bad char is encountered or if GIVENSTRING does not have
  266.  * '\0'; otherwise it returns number of characters, a number which could
  267.  * be 0; a colon is accepted as a string terminator and later stuff is
  268.  * deleted.  Numstars is set to the number of asterisks that were seen.
  269. */
  270. int     ParseString(nicestring, givenstring, len, numstars)
  271. register char   *nicestring;
  272. char    *givenstring;
  273. int     len;
  274. int    *numstars;
  275. {
  276. static char    *charlist = "+-_[]{}();/";
  277.     register char    *g;    /* indexes givenstring */
  278.     register int    ch;
  279.     int    starcount = 0;
  280.     int    j;
  281.  
  282.     /* check for a NUL to terminate GIVENSTRING and for ascii characters.
  283.      * This assures that the ctype(3) macros work properly.
  284.      */
  285.     g = givenstring;
  286.     for(j = 0; j < len && isascii(*g) && *g != '\0'; j++)
  287.         g++;
  288.     if(j == len || !isascii(*g))  {
  289.         *numstars = 0;
  290.         return(-1);    /* no '\0' anywhere or a nonascii character */
  291.     }
  292.     /* Translate upper case to lower case, skip spaces and stars,
  293.      * count stars, and copy allowable punctuation.
  294.      */
  295.     for(g = givenstring; *g != '\0'; g++)  {
  296.         ch = *g;
  297.         if(isupper(ch))            /* A-Z -> a-z */
  298. #ifdef _tolower
  299.             *nicestring++ = _tolower(ch);
  300. #else
  301.             *nicestring++ = tolower(ch);
  302. #endif
  303.         else if(isalnum(ch))        /* a-z or 0-9 */
  304.             *nicestring++ = ch;
  305.         else if(index(charlist, ch) != NULL)  /* allowed punctuation */
  306.             *nicestring++ = ch;
  307.         else if(ch == '*')        /* skip stars */
  308.             starcount++;
  309.         else if(!isspace(ch))        /* skip whitespace */
  310.             break;
  311.     }
  312.     if(*g != '\0')  {
  313.         if(ch != ':')               /* bad character */
  314.             return(-1);
  315.         else if(g[1] != '\0')  {
  316.             PRINT "remainder of line after colon is ignored\n");
  317.             beep();
  318.         }
  319.     }
  320.     *nicestring = '\0';
  321.     *numstars = starcount;
  322.     return((int) (g - givenstring));
  323. }
  324. /* ------------------------------------------------------------------------- */
  325. /* GETCOMMAND - fetch a string from the input device which is either
  326.  * the keyboard or a disk file.  Parse the string, making sure it has
  327.  * only legal characters, eliminating spaces and tabs and changing upper
  328.  * case letters to lower case.  If the string is legal,
  329.  * a 1 is returned, otherwise 0.  The string is copied into CodeName.
  330.  * On EOF the string "fileend" is copies into CodeName.
  331.  */
  332. int     GetCommand(CodeName) 
  333. char    *CodeName;
  334. {
  335.     int     StringReception;
  336.     char    *CrudeString;
  337.     char    HelpName[MAXCHAR];
  338.     int    numStars;    /* number of asterisks in input */
  339.  
  340.     CrudeString = GetGoodWord();    
  341.     if(CrudeString[0] == '\n' || CrudeString[0] == '\0')  {
  342.                 /* the zero occurs when a comment line is
  343.                    deleted */
  344.         CodeName[0] = '\0';
  345.         return(0);
  346.     }
  347.     StringReception = ParseString(CodeName, CrudeString, 20, &numStars);
  348.                 /* This puts the received string into a
  349.                    standard format and sticks the revised
  350.                    version in CodeName[] */
  351.     if(input == StInput) {
  352.         erase_line();
  353.         ret_erase_line(1);
  354.     }
  355.     if(StringReception < 0) {
  356.         PRINT "Bad input string; try again\n");
  357.         StringReception = 0;
  358.     } else if(StringReception > 0)  {
  359.                 /* if there is one asterisk in the string
  360.                    entered, that indicates help is needed; the
  361.                    spaces and asterisks have deleted and the
  362.                    result is code; numStars is the number of
  363.                    asterisks; their positions do not count */
  364.         if(numStars > 1) {
  365.             PRINT "too many asterisks     \n");
  366.             StringReception = 0;
  367.         } else if(numStars == 1) {
  368.             (void) strcpy(HelpName, CodeName);
  369.             givehelp(StringReception, HelpName, CodeName);
  370.             StringReception = 0;
  371.         } else
  372.             StringReception = 1;
  373.     } else
  374.         StringReception = 0;
  375.  
  376.     return(StringReception);
  377. }
  378. /* ------------------------------------------------------------------------- */
  379. /* FINDBEGINNING - Copy text from the document file, ignoring lines 
  380.  * that do not begin with '*'.
  381.  * First truncate any line beginning with a * so that it does not have any
  382.  * spaces between nontrivial characters, where trivial means ' ' or '*' or
  383.  * tab; then parse and decode the truncated string; if the returned code
  384.  * == helpcode, we have the desired line and the routine quits, returning
  385.  * a pointer to the desired line; it returns NULL at EOF or other problem.
  386.  */
  387. char     *FindBeginning(docfile, HelpName, CodeName)
  388. FILE    *docfile;
  389. char    *HelpName, *CodeName;
  390. {    
  391. static char    docstr[MAXCHAR+1];
  392.     char    line[MAXCHAR+1], *s, *cp;
  393.     int     k;
  394.     int    junk;
  395.  
  396.     while((cp = fgets(docstr, MAXCHAR, docfile)) != NULL) {
  397.         s = docstr;
  398.         if(*s == '*')  {
  399.             while(*s != '\0' && isspace(*s))   /* skip whitespace */
  400.                 s++;
  401.             for(k = 0; *s != '\0' && !isspace(*s); k++)
  402.                 line[k] = *s++;
  403.             line[k] = '\0';
  404.             if(ParseString(CodeName, line, 20, &junk) > 0 &&
  405.                 strcmp(HelpName, CodeName) == 0)
  406.                     break;
  407.         }
  408.     }
  409.     return(cp);
  410. }
  411. /* ------------------------------------------------------------------------- */
  412. givehelp(StringReception, HelpName, CodeName)
  413. int     StringReception;
  414. char    *HelpName, *CodeName;
  415. {
  416. #ifndef X11
  417.     char    Chr;
  418. #endif
  419.     char    *firstline, *cp;
  420.     char    docstr[MAXCHAR+1];
  421.     FILE    *docfile;
  422.  
  423.     if(StringReception == 0) {
  424.         erase_line();
  425.         printf("To get help on any command, type * and then the command, then <return>\n");
  426.         erase_line();
  427.         printf("Example:   *DOTS<return> (no spaces)");
  428.         ret_erase_line(2);
  429.         return;
  430.     }
  431.     if((docfile = fopen("commands.doc", "r")) == NULL)  {
  432.         PRINT "can't open document file for commands\n");
  433.         return;
  434.     }
  435.     if((firstline = FindBeginning(docfile, HelpName, CodeName)) == NULL) {
  436.         erase_line();
  437.         printf("Sorry-- no help available for what you entered.");
  438.         ret_erase_line(2);
  439.         return;
  440.     }
  441.     printf(firstline);
  442.     while((cp = fgets(docstr, MAXCHAR, docfile)) != NULL) {
  443.         if(docstr[0] == '*' && docstr[1] == '*')  {  /* temporary stop */
  444.             printf("PAUSE: hit Esc to quit; hit any other key for related info.\r");
  445. #ifdef X11
  446.             putchar('\n');
  447.             if(awaitkey(0) == ESC)
  448.                 break;
  449. #else
  450.             /* keep trying until a character is entered */
  451.             while((Chr = keycheck()) == 0);
  452.             printf( "                                     \r");
  453.             if(Chr == ESC)
  454.                 break;
  455. #endif
  456.             printf(docstr + 2);
  457.         } else if(docstr[0] == '*') {
  458.             break;
  459.         } else if(docstr[0] != '.' && !isblank(docstr))  {
  460.             printf(docstr);
  461.         }
  462.     }
  463.     if(cp == NULL) {
  464.         printf("end of file \n");
  465.         erase_line();
  466.         return;
  467.     }
  468.     fclose(docfile);
  469. }
  470. /* ------------------------------------------------------------------------- */
  471. /* CHECKFORINT - return the integer value in the string S if it contains
  472.  * a valid integer other than -9999.  Otherwise return -9999.
  473.  */
  474. int     CheckForInt(s)
  475. register char   *s;
  476. {
  477.     int     isnegative = 0;
  478.     int     value = 0;
  479.  
  480.     if(*s == '-') {
  481.         isnegative = 1;
  482.         s++;
  483.     }
  484.     while(isdigit(*s))  {
  485.         value = value * 10 + *s - '0';
  486.         s++;
  487.     }
  488.     if(isnegative)
  489.         value = -value;
  490.     return(*s == '\0' ? value : -9999);
  491. }
  492. /* ------------------------------------------------------------------------- */
  493. /* GETMAPNAME - place the map name in global variable MapName.
  494.  * Return 1 if the name is acceptable and 0 otherwise.
  495.  * The routine does not guarantee that a process by that name exists.
  496.  * To prevent an infinite loop when reading from a file, we return the
  497.  * name "xx" to cause the program to exit if an eof of file is detected.
  498.  */
  499. int     GetMapName() 
  500. {        
  501.     int     StringReception;
  502.     char    *CrudeString;
  503.     int    junk;
  504.  
  505.     
  506.     CrudeString = GetGoodWord();
  507.     if(strcmp(CrudeString, "fileend") == 0)  {
  508.         (void) strcpy(MapName, "xx");
  509.         StringReception = 1;
  510.     } else
  511.         StringReception = ParseString(MapName, CrudeString, 20, &junk);
  512.     if(StringReception < 0)
  513.         PRINT "Try again\n");
  514.     return(StringReception > 0);
  515. }/* ------------------------------------------------------------------------- */
  516. OptionsHelp()         /*  called by interrupt() */
  517. {
  518.     char   *option,*note;
  519.     char    keystroke[2];
  520.     int     kk;
  521.  
  522.  
  523.     scr_rowcol(15,0);
  524.     erase_line();
  525.     note = 
  526. "Hit a key for that interrupt's description or a key for an interrupt menu  \n"
  527. ;    PRINT note);
  528.     PRINT warning);
  529.     erase_line();
  530.     ret_erase_line(7);
  531. #ifdef X11
  532.     kk = awaitkey(0);
  533. #else
  534.     while((kk = keycheck()) == 0);         /* wait for input */
  535. #endif
  536.     scr_rowcol(15,0);
  537.     erase_line();
  538.  
  539.  
  540.     switch(kk)  {
  541.     case '+':        /* to declare picture finished */
  542.     case '-':
  543.     case Home:
  544.     case PgUp:
  545.         option = "+";
  546.         break;
  547.     case 'e':
  548.     case 'E':
  549.         option = "e";
  550.         break;
  551.     case 's':
  552.     case F1:
  553.     case F2:
  554.     case F3:
  555.     case F4:
  556.     case F10:
  557.         option = "s";
  558.         break;
  559.     case F5:
  560.     case F6:
  561.     case F7:
  562.     case F8:
  563.     case F9:    /* we need an ascii character and though F has
  564.              * nothing do with color, it'll do for now */
  565.         option = "F";
  566.         break;
  567.     case 'x':
  568.     case 'y':
  569.         option = "x";
  570.         break;
  571.     case ESC:
  572.         option = "Esc";
  573.         break;
  574.     case DOWN:
  575.     case UP:
  576.     case RIGHT:
  577.     case LEFT:
  578.     case End:
  579.     case PgDn:
  580.         option = "DOWN";
  581.         break;
  582.     default:
  583.         if(isdigit(kk))
  584.             option = "0";
  585.         else {
  586.             keystroke[0] = kk;
  587.             keystroke[1] = '\0';
  588.             option = keystroke;
  589.         }
  590.         break;
  591.     }
  592.     if(option != NULL)
  593.         getText("yintrpt.doc", option);
  594.     erase_line();
  595.     ret_erase_line(1);
  596.     PRINT "Hit r to refresh the screen.\n");
  597.     erase_line();
  598.     ResetScrnLineAtTop();
  599. }
  600. /* ------------------------------------------------------------------------- */
  601. /* GETTEXT - search for a line beginning with an asterisk and the rest of which
  602.  * exactly matches the string given by OPTION.
  603.  */
  604. getText(filename, option)
  605. char   *option,
  606.        *filename;
  607. {
  608.     FILE   *fp;
  609.     char   *ptr;        /* used to see if we get to end of file */
  610.     char    string[MAXCHAR+1];
  611.  
  612.     if((fp = fopen(filename, "r")) == NULL)  {
  613.         erase_line();
  614.         PRINT "\n    Cannot locate text file %s    \n", filename);
  615.         return;
  616.     }
  617.  
  618.     /* Read lines until EOF */
  619.     while((ptr = fgets(string, MAXCHAR, fp)) != NULL)  {
  620.         deleteLF(string);    /* delete trailing newline */
  621.         if(string[0] == '*' && strcmp(&string[1], option) == 0)  {
  622.                     /* have starting line so print info */
  623.             while(fgets(string, MAXCHAR, fp) != NULL &&
  624.                 string[0] != '*')  {
  625.                 erase_line();
  626.                 PRINT string);
  627.             }
  628.             break;
  629.         }
  630.     }
  631.     if(ptr == NULL)  {
  632.         erase_line();
  633.         PRINT "    ********** No information found **********\n");
  634.         PRINT warning);
  635.         erase_line();
  636.     }
  637.     fclose(fp);
  638.     return;
  639. }
  640. /* ------------------------------------------------------------------------ */
  641. /* DELETELF - terminate the given string at the first newline. */
  642. deleteLF(s)
  643. register char    *s;
  644. {
  645.     if(s == NULL)
  646.         return;
  647.     while(*s != '\n' && *s != '\0')
  648.         s++;
  649.     if(*s == '\n')
  650.         *s = '\0';
  651.     return;
  652. }    
  653. /* ------------------------------------------------------------------------- */
  654. /* ISBLANK - return 1 if the string consists only of whitespace, 0 otherwise. */
  655. int    isblank(s)
  656. register char    *s;
  657. {
  658.     while(isspace(*s))
  659.         s++;
  660.     return(*s == '\0');
  661. }
  662. /* ------------------------------------------------------------------------- */
  663. /* TESTFORPIC - Returns 1 if S ends in ".pic" or ".PIC". */
  664. int     TestForPic(s) 
  665. register char    *s;
  666. {
  667.     while(*s != '.' && *s != '\0')
  668.         s++;
  669.     return(strcmp(s, ".pic") == 0 || strcmp(s, ".PIC") == 0);
  670. }
  671.  
  672. /* X Windows has its own set of keycodes which we handle in ywindows.c */
  673. #ifndef X11
  674. /********************************** YKEYCHK.C ********************************/
  675. /********************* (C) 1986,7,8 by JAMES A. YORKE ************************/
  676.  
  677. /*************************************************** 
  678. ASCII character codes
  679.  can be found in Microsoft C Compiler manual, p. 175 
  680. Some ascii codes -- see BASIC manual appendix G 
  681.     48-57: 0,1,...,9
  682.     65-90: A,...,Z
  683.     97-122: a,...,z
  684. Notice above defined codes 71,72,73,75,77,79,80,81
  685.                 G  H  I  K  M  O  P  Q
  686. Some Extended Codes --preceeded by a character 0
  687.     120-131: Alt 1,2,...,0,-,=    
  688.     59-68:   F1-F10
  689.     84-93:   SHIFTED F1-F10
  690.     94-103   Ctrl F1-F10
  691.     104-103  Alt F1-F10
  692.     16-25 Alt Q,W,E,R,T,Y,U,I,O,P
  693.     30-38 Alt A S D F G H J K L
  694.     44-50 Alt Z X C V B N M
  695. ****************************************************/
  696. int     keycheck() {        /* This routines checks to see if a key has
  697.                    been hit; if not, it returns 0; if it has,
  698.                    it fetches the char and returns it; it may
  699.                    have to check twice since extended codes
  700.                    preface a non zero character with a zero; */
  701.     int     ch;
  702.     if(ChkKeyStatus() == 0)
  703.         return(0);
  704.     if((ch = ci()) != 0)    /* ci is a desmet routine */
  705.         return(ch);
  706.     return(-ci());
  707. }
  708. #endif
  709.  
  710.